PROC     = 32MX220F032D
CC       = xc32-gcc
CXX      = xc32-g++
AS	 = xc32-as
BIN2HEX  = xc32-bin2hex
FLASH    = mphidflash -n -r
CFLAGS   = -Wall -O2 -MMD -g -mprocessor=$(PROC)
CXXFLAGS = -Wall -O2 -MMD -g -mprocessor=$(PROC)
ASFLAGS  = -mprocessor=$(PROC) -g -Wall
LDFLAGS  = -mprocessor=$(PROC) -Wl,--report-mem
LDLIBS   = -lm -lc

PICPERFTEST_OBJECTS = picperftest.o  quantize96.o rand.o interpolate.o interpolate_intern.o
PICPERFTEST_ELF = picperftest.elf
PICPERFTEST_HEX = picperftest.hex
PICPERFTEST_LINKER = $(CC)

all: ppf

.PHONY: clean all ppf writeppf

%.hex: %.elf
	$(BIN2HEX) -a $<

clean:
	rm -f *.o *.d *.elf *.hex

ppf: $(PICPERFTEST_HEX)

$(PICPERFTEST_ELF): $(PICPERFTEST_OBJECTS)
	$(PICPERFTEST_LINKER) $(LDFLAGS) -o $@ $^ $(LDLIBS)

writeppf: $(PICPERFTEST_HEX)
	$(FLASH) -w $<

include $(wildcard *.d)
